#include"../src/server.hpp"


void Connected(const PtrConnection& conn)
{
    DBG_LOG("NEW CONNECTION! :%p",conn.get());
}

void OnClosed(const PtrConnection& conn)
{
    DBG_LOG("CLOESE CONNECTION! :%p",conn.get());
}

void OnMessage(const PtrConnection& conn,Buffer* buf)
{
    DBG_LOG("%s",buf->GetReadPosition());
    buf->MoveReadOffset(buf->ReadAbleSize());
    std::string str = "hello world";
    conn->Send(&str[0],str.size());
}

int main()
{
    TcpServer server(8085);
    server.SetThreadCount(3);
    // server.EnableActiveRelease(5);
    server.SetClosedCallback(OnClosed);
    server.SetConnectedCallback(Connected);
    server.SetMessageCallback(OnMessage);
    server.Start();

}